
import BaseArray from './base-array'

import { reactive } from 'vue'

import type {
  IStateKey
} from '../types/type'

/**
 * 给 BaseArray 套个壳，加上 reactive 实现响应性 & IState
 * @param val 数组或者函数
 * @returns 
 */
export default function createArray<T>(
  val: Array<T> | (() => Array<T>),
  id: IStateKey = Symbol('_array')
) {
  const re = new BaseArray<T>(val, id)
  const ret = reactive(re)
  return ret as BaseArray<T> & T
}